const { Buffer } = require('node:buffer');
class Foo {
  [Symbol.toPrimitive]() {
    return 'this is a test';
  }
}
const buf = Buffer.from(new Foo(), 'utf8');
// Prints: <Buffer 74 68 69 73 20 69 73 20 61 20 74 65 73 74>
